﻿
using System;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
using ERP.Workflow.Designer.Domain;
using ERP.Workflow.Designer.Domain.IRepository;
using ERP.Workflow.Designer.EntityFrameworkCore.Repositorys;
using ERP.Abp.TenantManagement.EntityFrameworkCore;
using ERP.Abp.PermissionManagement;

using ERP.Abp.PermissionManagement.EntityFrameworkCore;

namespace ERP.Workflow.Designer.EntityFrameworkCore
{
    [DependsOn(
       typeof(WorkflowDesignerDomainModule),
        typeof(AbpEntityFrameworkCoreModule),
        typeof(AbpTenantManagementEntityFrameworkCoreModule),
        typeof(AbpPermissionManagementEntityFrameworkCoreModule)
    )]
    public class WorkflowDesignerEntityFrameworkCoreModule:AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAbpDbContext<WorkflowDesignerDbContext>(options =>
            {
                /* Remove "includeAllEntities: true" to create
                 * default repositories only for aggregate roots */
                options.AddDefaultRepositories(includeAllEntities: true);
                //  options.AddDefaultRepositories<IWorkflowDesignerDbContext>();
                options.AddRepository<Node, NodeRepository>();
                options.AddRepository<Link, LinkRepository>();
                options.AddRepository<Definition, DefinitionRepository>();
                options.AddRepository<LinkLabel, LinkLabelRepository>();
                options.AddRepository<LinkVertex, LinkVertexRepository>();
                options.AddRepository<Port, PortRepository>();
            });

            Configure<AbpDbContextOptions>(options =>
            {
                /* The main point to change your DBMS.
                 * See also WorkflowEngineMigrationsDbContextFactory for EF Core tooling. */
                options.UseMySQL();
            });
        }
    }
}